using System;
using System.Collections.Generic;
using System.Text;
using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;

namespace Sedna.Core.Controls.Actions
{
    public class CheckConditionFlagAction: AbstractAction
    {
        private string conditionFlagPath;
        private string trueKey;
        private string falseKey;

        public string ConditionFlagPath
        {
            set { conditionFlagPath = value; }
        }

        public string TrueKey
        {
            set { trueKey = value; }
        }

        public string FalseKey
        {
            set { falseKey = value; }
        }

        public override IActionResult Execute(IExecutionContext executionContext)
        {
            object flag = executionContext.GetPropertyValue(conditionFlagPath);
            
            if (flag != null && flag is bool)
            {
                if ((bool)flag)
                    return CreateResult(trueKey);
            }
            return CreateResult(falseKey);
        }
    }
}
